/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.sales.generics.client.view.functions;

import br.com.sales.generics.client.nametoken.NameTokens;
import br.com.sales.generics.client.presenter.functions.PopUpFunctionsPresenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl;

/**
 *
 * @author v
 */
public class PopUpFunctionsView extends ViewImpl implements PopUpFunctionsPresenter.Display {

    private final static PopUpFunctionsViewUiBinder uiBinder = GWT.create(PopUpFunctionsViewUiBinder.class);
    @UiField
    PopupPanel container;
    @UiField
    HorizontalPanel horizontalPanel;
    private final Hyperlink peopleCadastre = new Hyperlink("Pessoas", NameTokens.REGISTERPERSON);
    private final Hyperlink productsCadastre = new Hyperlink("Produtos", NameTokens.REGISTERSPRODUCTS);
    private final Hyperlink productsNewProduct = new Hyperlink("Solicitação de compra", NameTokens.REGISTERNEWITEM);

    @Inject
    public PopUpFunctionsView() {
        container = uiBinder.createAndBindUi(this);
    }

    @Override
    public void build() {
        container.setAutoHideEnabled(true);
        container.setAutoHideOnHistoryEventsEnabled(true);
        horizontalPanel.add(peopleCadastre);
        horizontalPanel.add(productsCadastre);
        horizontalPanel.add(productsNewProduct);
    }

    @Override
    public void hide() {
        container.hide();
    }

    @Override
    public void show() {
        container.setPopupPosition(0, 50);
        container.show();
    }

    @Override
    public Widget asWidget() {
        return container;
    }

    interface PopUpFunctionsViewUiBinder extends UiBinder<PopupPanel, PopUpFunctionsView> {
    }
}
